function checkOldPwd() {
    var oldPwd = document.getElementById("oldPwd");
    if (oldPwd.value.replace(/\s+/g, '') == "") {
        alert("旧密码不能为空！");
        oldPwd.classList.add("wrong");
        return false;
    }
    else {
        oldPwd.classList.remove("wrong");
        return true;
    }
}


function checkNewPwd() {
    var newPwd = document.getElementById("newPwd");
    newPwdValue = newPwd.value;
    // 字符串中是否同时包含字母、数字、特殊符号且长度大于等于8
    var regex = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=])(?=\S+$).{8,}$/;
    if (!regex.test(newPwdValue) || newPwdValue == "") {
        alert("密码格式错误！");
        newPwd.classList.add("wrong");
        return false;
    }
    else {
        newPwd.classList.remove("wrong");
        return true;
    }
}

function checkReNewPwd() {
    var newPwd = document.getElementById("newPwd");
    var newrePwd = document.getElementById("newrePwd");
    if (checkNewPwd()) {
        if (newrePwd.value.replace(/\s+/g, '') != newPwd.value.replace(/\s+/g, '')) {
            newrePwd.classList.add("wrong");
            alert("两次密码不一致！");
            return false;
        } else {
            newrePwd.classList.remove("wrong");
            return true;
        }
    }else{
        newrePwd.classList.add("wrong");
        return false;
    }
}

function checkPhone() {
    var docPhone = document.getElementById("docPhone");
    var regex = /^1[3-9]\d{9}$/;
    if (docPhone.value == "") {
        docPhone.classList.add("wrong");
        alert("手机号不能为空!");
        return false;
    } else {
        if (!regex.test(docPhone.value)) {
            docPhone.classList.add("wrong");
            alert("手机号格式不正确!");
            return false;
        } else {
            docPhone.classList.remove("wrong");
            return true;
        }
    }
}

function checkForm() {
    if (checkNewPwd() && checkReNewPwd() && checkPhone()) {
        return true;
    } else {
        return false;
    }
}